<template>
	<view class="identityForm" v-if="userInfo.authnStatus===0">
		<uni-forms :modelValue="identityInfo" ref="identityform" validate-trigger="bind">
			<uni-forms-item label="身份证号" name='idCard'>
					<uni-easyinput v-model="identityInfo.idCard" placeholder="请输入身份证号" />
			</uni-forms-item>
			<uni-forms-item label="姓名">
					<uni-easyinput v-model="identityInfo.realName" placeholder="请输入姓名" />
			</uni-forms-item>
		</uni-forms>
		<view class="confirmBtn" @click="identityConfirm">
			确定
		</view>
	</view>
	<view class="head" v-if="userInfo.authnStatus===1">
		您已完成认证
	</view>
</template>

<script>
	import {identityAuthn} from '@/api/user.js'
	export default {
		onShow() {
			this.userInfo = uni.getStorageSync('userInfo');
		},
		data() {
			return {
				userInfo:{},
				identityInfo:{
					idCard:'',
					realName:'',
				},
			}
		},
		methods: {
			identityConfirm(){
				identityAuthn(this.identityInfo).then(res=>{
					if(res.data.code==200){
						uni.setStorageSync('userInfo', res?.data?.data);
						uni.setStorageSync('token', res?.data?.data?.token);
						uni.switchTab({
							url:'/pages/my/my'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss">
.identityForm{
	margin: 30rpx 0;
}
.confirmBtn{
	width: 92%;
	margin: 30rpx auto;
	height: 80rpx;
	line-height: 80rpx;
	text-align: center;
	color: #fff;
	font-size: 32rpx;
	border-radius: 20rpx;
	background-color: #8DC7DF;
	box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.1);
}
.head{
	margin-top: 320rpx;
	text-align: center;
	font-size: 50rpx;
	color:#8DC7DF;
}
// ----------------------------
.uni-forms-item__label{
	color: #333 !important;
	font-size: 36rpx!important;
	padding-left: 30rpx!important;
}
.is-input-border{
	border: none!important;
	border-bottom: 1rpx solid #f5f5f5!important;
}
.uni-forms-item{
	margin-bottom: 30rpx!important;
}
</style>
